<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>考勤录入</title>
<jsp:include page="${home}/assets/common_inc_new.jsp"  flush="true"></jsp:include>
<script type="text/javascript" src="${home}/system/common/scripts/utils.js"></script>
<!-- <script type="text/javascript" src="/zhcy/zrf/utils.js"></script> -->
<link rel="stylesheet" type="text/css" href="../css/index.css">
<script type="text/javascript">
	var result;
	var page_current=1;
	var page_size=0;
	var page_interval=10;
	//var id=window.setInterval(doCopy,5000);定时任务
	function ui_listReqInfos(){
		page_size=$("#txtPageNum").val();
		var queryCallBack=function(reqInfos,callResult){
			if(callResult.response_code == '0'){
				$.dialog.tips("查询成功...");
				ui_addReqInfo(reqInfos.content.result.list);
				var htmlMsg2=OutPageListAjax(page_size,page_current, reqInfos.content.result.total,  pageChangeCallback, page_interval);
				$("#PageContent").html(htmlMsg2);
				page_current=1;
			}
		}
		listReqInfos(queryCallBack);
	}

	function pageChangeCallback(pageid){
			page_current=pageid;
			ui_listReqInfos();
	}

	function listReqInfos(callBackList){
		var head={
			"service_name":"cn.dy.workatten.service.WorkAttenService",
			"operation_name":"queryAuditWorkAttendList"
		}
		if(right_click_node.id==null || right_click_node.id<=0||right_click_node.id==""){
            alert("请选择部门");
            throw SyntaxError();
        }
		var param={
			"dept_id": right_click_node.id,
			"audit_sts": $("#statusSelect").val(),
			"beginTime":$("#begin_time").val(),
			"endTime":$("#end_time").val(),
			"pageNum": page_current,
			"pageSize": page_size
		}
		var myCallBack=function(data,callResult){
		if(callBackList){
			callBackList(data,callResult);
			}
		}
		var options={
			 "handleError": false,
		    "showProgressBar":false,
		    "timeout":60000*10
		 };
		$.ServiceAgent.JSONInvoke(head,param,myCallBack,options);
	}

	function obj2Str(obj) {
	  return JSON.stringify(obj).replace(/"/g, "'");
	}

	function goDetails(item) {
		console.log(item);
		window.location.href = "details.jsp?application_id=" + item.id + "&sts=" + item.sts + "&dept_id=" + item.dept_id;
	}

	var stsMap = {
		1: '待审批',
		2: '审批通过',
		3: '审批未通过',
		0: '未提交'
	};

	function ui_addReqInfo(data){
		var tableTh = "<tr>"
			+ "<th width=\"10%\">序号</th>"
			+ "<th width=\"10%\">部门</th>"
			+ "<th width=\"10%\">考勤日期</th>"
			+ "<th width=\"10%\">审批状态</th>"
			+ "<th width=\"10%\">修改时间</th>"
			+ "<th width=\"10%\">修改人员</th>"
			+ "<th width=\"10%\">操作</th>"
		+ "</tr>";
		$("#resultgrid").html(tableTh);
			for(var i=0;i<data.length;i++){
					var reqInfo=data[i];
					var reqInfoStr = obj2Str(reqInfo);

					var htmlMsg="<tr>"
					+"<td align=\"center\">"+((page_current-1)*page_size + i + 1)+"</td>"
					+"<td align=\"center\">"+reqInfo.deptName+"</td>"
					+"<td align=\"center\">"+(reqInfo.attendance_month + reqInfo.attendance_days)+"</td>"
					+"<td align=\"center\">"+stsMap[reqInfo.sts]+"</td>"
					+"<td align=\"center\">"+reqInfo.create_time+"</td>"
					+"<td align=\"center\">"+reqInfo.staffName+"</td>"
					+"<td align=\"center\" class=\"choose\" onclick=\"goDetails(" + reqInfoStr + ")\">查看</td>"
					+"</tr>";
					$("#resultgrid").append(htmlMsg);

				}
		}

		function getYMD(){
		  var date = new Date();
		  var seperator1 = "-";
		  var month = date.getMonth() + 1;
		  var strDate = date.getDate();
		  if (month >= 1 && month <= 9) {
		       month = "0" + month;
		   }
		  if (strDate >= 0 && strDate <= 9) {
		      strDate = "0" + strDate;
		   }
		  return date.getFullYear() + seperator1 + month + seperator1 + strDate;
		}

	function add() {
		window.location.href="add.jsp";
	}

	$(document).ready(function(){
		// ui_listReqInfos();
	});
</script>

</head>
<body class="mainbody">
			<!-- 导航栏 -->
			<div class="location">
				<a href="javascript:;" class="home"><i></i><span>考勤审批</span>
				</a>
			</div>

			<!-- 操作栏 -->
			<div class="toolbar-wrap">
				<div id="floatHead" class="toolbar">
					<div class="r-list" style="float: none">
						<input type="hidden" name="部门id" id="dept_id" class="operation_date" placeholder="部门id" />
						<input type="text" name="txtdept" id="txtdept" for="txtdept" placeholder="请选择部门" style="float: left" sucmsg=" " style="width: 150px;" class="keyword date" readonly="readonly" onclick="ShowAction()" />
						<!-- <span class="operation_time">审批状态:</span>-->
						<div class="rule-single-select"
							style="float: left; margin-left: 5px;">
							<select id="statusSelect" style="width: 150px;">
								<option value="">
									请选择审批状态
								</option>
								<option value="1">
									待审批
								</option>
								<option value="2">
									审批通过
								</option>
								<option value="3">
									审批未通过
								</option>
								<option value="0">
									未提交
								</option>
							</select>
						</div>
						<!-- <span class="operation_time">考勤日期:</span>-->
						<input name="begin_time" type="text" id="begin_time"
							class="keyword date"
							onfocus="WdatePicker({dateFmt:&#39;yyyy-MM-dd HH:mm:ss&#39;})"
							datatype="*1-50" errormsg="请选择正确的日期" sucmsg=" " nullmsg=" "
							placeholder="考勤开始日期"  />
						<!-- <span class="hx">--</span> -->
						<input name="end_time" type="text" id="end_time" class="keyword date"
							onfocus="WdatePicker({dateFmt:&#39;yyyy-MM-dd HH:mm:ss&#39;})"
							datatype="*1-50" errormsg="请选择正确的日期" sucmsg=" " nullmsg=" "
							placeholder="考勤结束日期"  />
						<!--<a id="lbtnSearch" class="reset" onclick="queryGrid();"><span>查询</span></a>-->
						<a id="lbtnSearch" class="btn-search" onclick="ui_listReqInfos();"><i></i><span>查询</span></a>
					</div>


				</div>
			</div>

		<!--查询结果列表-->
		<table width="100%" border="0" cellpadding="0" cellpadding="0" class="ltable" id="resultgrid">
			<tr>
				<th width="10%">序号</th>
				<th width="10%">部门</th>
				<th width="10%">考勤日期</th>
				<th width="10%">审批状态</th>
				<th width="10%">修改时间</th>
				<th width="10%">修改人员</th>
				<th width="10%">操作</th>
			</tr>
		</table>

		<!--内容底部-->
		<div class="line30"></div>
		<div class="pagelist">
			<div class="l-btns">
				<span>显示</span>
				<input type="text" name="txtPageNum" value="10"
				onchange="javascript:setTimeout(&#39;__doPostBack(\&#39;txtPageNum\&#39;,\&#39;\&#39;)&#39;, 0)"
				onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;"
						id="txtPageNum" class="pagenum"
						onkeydown="return checkNumber(event);"/>
				<span>条/页</span>
			</div>
			<div id="PageContent" class="default">
			</div>
		</div>

		<!-- 部门选择弹出框 -->
		<script id="recharge-tpl" type="text/template">
			<div id="role" style="width: 250px; float: left; ; height: 300px;background: #eeeeee">
				<div class="title">部门列表</div>
				<div id="treeParentArea" valign=top style="width: 100%;height: 500px;">
					<ul id="tree" class="ztree" style="overflow:auto;margin:0px;height:698px"></ul>
				</div>
			</div>
		</script>

		<script type="text/javascript">
			$(function(){
				getCurrentDept();
			});

			function ShowAction() {
				var param = {'0':'模版描述'};
				var tit = "部门选择";
				jsdialog(tit, RpTpl($("#recharge-tpl").html(), param), "", "None", function (data) {  alert(data);},
					function (data) {
						//alert('ok---'+right_click_node.id);
						//alert(data);
						$("#txtdept").val(right_click_node.name);
						$("#dept_id").val(right_click_node.id);
					},
					function () {
						createTree();
					});
			}
			function RpTpl(tpl, obj) {
				var re = tpl;
				if (!tpl || tpl.length <= 0) return re;
				if (!obj || typeof obj != "object") return re;
				for (k in obj) {
					re = re.replace("{#" + k + "#}", obj[k]);
				}
				return re;
			}

		</script>

		<script type="text/javascript"
				src="/xyzg/system/common/scripts/utils.js"></script>
		<script type="text/javascript"
				src="/xyzg/system/common/scripts/zDialog.js"></script>
		<%--<script type="text/javascript" src="/xyzg/scripts/lhgdialog/lhgdialog.js?skin=idialog"></script>--%>
		<script type="text/javascript" src="/xyzg/scripts/zTree/js/jquery.ztree.all-3.5.min.js"></script>
		<script src="/xyzg/workatten/attendance/deptTreeJs.js"></script>
		<link rel="stylesheet" href="/xyzg/scripts/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">

</body>
</html>
